home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 March / Gamestar_71_2005-03_dvd.iso / Dema / willofsteel_demo.exe / {app} / Data / scripts / init.pls < prev    next >
Text File  |  2004-10-23  |  2KB  |  79 lines

  1. -----------------------------------------------------------
  2. -- Global return value in loading/creation of new objects
  3. -----------------------------------------------------------
  4. Loading_RetVal = 0
  5.  
  6. ------------------------------------------
  7. ---------- Init functions ----------------
  8. ---------- loading script ----------------
  9. ------------------------------------------
  10.  
  11.  
  12. -- creating one object from object's table
  13.  
  14. function CreateObject (ObjectTable)
  15.  
  16.     -- create it trough ClassFarm
  17.    local newobject = 0
  18.    newobject = P_CreateInstance(ObjectTable.CLSID, ObjectTable.Name, ObjectTable.OptionalID, ObjectTable.IsDescription, ObjectTable.Description)
  19.    
  20.    if (newobject ~= nil) then
  21.  
  22.        -- start setting properties
  23.  
  24.          local prop = "prop_"
  25.          local index = 1;
  26.          local property = prop..index
  27.  
  28.          while (ObjectTable[property] ~= nil) do
  29.             local property_name = ObjectTable[property][1]
  30.             local property_clsid = ObjectTable[property][2]
  31.             local property_val = ObjectTable[property][3]
  32.             
  33.             -- test for vector
  34.             if type(property_val) == "table" then
  35.                 local tb = property_val
  36.                 local i=1;
  37.                 while (i~=0) do
  38.                     vecelem_name = tb[i];
  39.                     if (vecelem_name == nil) then do break end
  40.                     else
  41.                        P_InsertObject(newobject, property_name, property_clsid, vecelem_name)
  42.                        i = i+1;
  43.                     end;
  44.                 end;
  45.             else
  46.                 -- set object's property
  47.                 P_SetProperty(newobject, property_name, property_clsid, property_val)
  48.             end;
  49.             index = index +1
  50.             property = prop..index;
  51.          end;
  52.    end;
  53.    --return newobject;
  54.    
  55.    -- set global return value
  56.    Loading_RetVal = newobject;
  57.    
  58. end;
  59.  
  60. function ModifyObject (ObjectTable)
  61.  
  62.    
  63. end;
  64.  
  65. function CreateGUI (ObjectName)
  66.  
  67.     -- create it trough ClassFarm
  68.    local newobject = 0
  69.    newobject = P_CreateInstance( 29, ObjectName, 0, 0)
  70.    
  71.    -- set global return value
  72.    Loading_RetVal = newobject;
  73.    
  74.    SETACTIVEGUI(newobject);
  75.    
  76.    --return newobject;
  77.    return newobject;
  78. end;
  79.